<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateBannerShopMappings extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('banner_shop_mappings', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0)->comment('店铺id');
            $table->unsignedInteger('bannerId')->default(0)->comment('bannerId');
            $table->unsignedTinyInteger('status')->default(0)->comment('状态 0 正常 1 停用');
            $table->integer('createdAt')->default(0)->comment('创建时间');
            $table->integer('createdByUid')->default(0)->comment('创建人');
            $table->integer('updatedAt')->default(0)->comment('修改时间');
            $table->integer('updatedByUid')->default(0)->comment('修改人');
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除 1：已删除");

            $table->index(['shopId', 'isDeleted'], 'idx_shopId_isDeleted');
            $table->index('bannerId', 'idx_bannerId');
            $table->comment = 'banner店铺关联表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('banner_shop_mappings');
    }
}
